package Meituan;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: leiwenkang02@meituan.com
 * @date: 2019/3/12
 * @time: 19:34
 */
public class DoubleCompare {
    public static void main(String[] args) {
        double chanceSum = 0.0;
        List<Double> list = new ArrayList<>();
        list.add(0.123);
        list.add(0.277);
        list.add(0.325);
        list.add(0.275);
        for (double chance : list) {
            chanceSum += chance;
        }
        System.out.println(chanceSum == 1);
    }

    public static boolean isEqual(double v1, double v2) {
        return compareDouble(v1, v2) == 0;
    }

    public static int compareDouble(double v1, double v2) {
        BigDecimal b1 = BigDecimal.valueOf(v1);
        BigDecimal b2 = BigDecimal.valueOf(v2);
        return b1.compareTo(b2);
    }
}
